import moment from 'moment'
import { nullDisplay } from '../utils'
// 时长
export default {
  props: {
    value: [String, Number],
    options: Object
  },
  render(h) {
    if (this.value === null || this.value === this.options.nullValue) {
      return nullDisplay(h, this.options)
    }
    const duration = moment
      .duration(this.value * 1000)
      .locale('zh-CN')
      .humanize()
    return h(
      'div',
      {
        attrs: this.options
      },
      duration
    )
  }
}
